/*
 * VueImage.java
 *
 * Created on 21 novembre 2007, 00:08
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package Vue;

import Modele.*;

import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JPanel;
/**
 *
 * @author Soufiane GARCH
 * If you want to change anything in this source, please contact me
 */
public class VueImage extends JPanel{
    
    private ModeleImage mImg;
    private int x;
    private int y;
    /** Creates a new instance of VueImage */
    public VueImage(ModeleImage mImg) {
        super();
        this.mImg = mImg;
        x = -1;
        y = -1;
        this.setPreferredSize(new Dimension(900, 800));
        //this.setPreferredSize(new Dimension(this.mImg.getLargeur(), this.mImg.getHauteur()));
        //JScrollPane scroll = new JScrollPane(this);
        update();
    }
    
    public VueImage(ModeleImage mImg, int x, int y) {
        super();
        this.mImg = mImg;
        this.x = x;
        this.y = y;
        this.setPreferredSize(new Dimension(this.x, this.y));
        //this.setPreferredSize(new Dimension(this.mImg.getLargeur(), this.mImg.getHauteur()));
        //JScrollPane scroll = new JScrollPane(this);
        update();
    }
    
    public void update(){
        super.repaint();
    }
    
        
    @Override
    public void paintComponent(Graphics g) {
                super.paintComponent(g);
                //int height = this.getSize().height;
                //int width = this.getSize().width;  
                /*
                if ( (x == -1) && (y == -1) ){
                    x = mImg.getLargeur();
                    y = mImg.getHauteur();
                }*/
                
                g.drawImage(mImg.getImage(),0,0, mImg.getLargeur(), mImg.getHauteur(), this);
    } 
    
    /*   
    public static void main(String args[]) {
        ModeleImage mi1 = new ModeleImage("C:\\Documents and Settings\\garch0011\\Bureau\\test\\Automne.jpg");
       
        VueImage img1 = new VueImage(mi1);
      
        
        JFrame fe = new JFrame();
        Container cont = fe.getContentPane();
        JPanel pan = new JPanel();
        pan.setLayout(new FlowLayout());
        pan.add(img1);
        
        cont.add(pan);
        fe.setSize(800, 600);
        fe.setEnabled(true);
        fe.setVisible(true);
    }*/
}
